package com.cooper.controllers.dev;

import java.util.Enumeration;

import net.paoding.rose.web.Invocation;
import net.paoding.rose.web.annotation.rest.Get;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cooper.controllers.Controller;
import com.cooper.core.JsonResult;
import com.cooper.util.Controllers;

/**
 * 
* @Description: 
* @version: v1.0.0
* @author: tianlg
* @date: Apr 24, 2015 4:56:01 PM
*
* Modification History:
* Date         Author          Version            Description
*---------------------------------------------------------*
* Apr 24, 2015      tianlg          v1.0.0
 */
public class VoteController extends Controller {
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Get
	public Object execute(Invocation inv, JsonResult json){
		String clientIp = Controllers.getIpAddr(inv.getRequest());
		logger.debug("CLIENT IP IS:{}", clientIp);
		
		StringBuffer buffer = new StringBuffer();
		Enumeration<String> headerNames = inv.getRequest().getHeaderNames();
		while(headerNames.hasMoreElements()){
			String headerName = headerNames.nextElement();
			buffer.append(headerName).append("==").append(inv.getRequest().getHeader(headerName));
			buffer.append("\n");
		}
		json.setMessage(buffer.toString());
		return json;
	}
}
